<?php

/*
 * cui:phpstorm
 * 2021/7/23
 * 21:34
 * User: s1mple_qcloud@163.com
 *
 */

namespace App\Admin\Controllers\Order;

use App\Admin\Repositories\CmcPromotionsOrderlist;
use Dcat\Admin\Form;
use Dcat\Admin\Grid;
use Dcat\Admin\Show;
use Dcat\Admin\Http\Controllers\AdminController;

class CmcPromotionsOrderlistController extends AdminController
{
    /**
     * Make a grid builder.
     *
     * @return Grid
     */
    protected function grid()
    {
        return Grid::make(new CmcPromotionsOrderlist(), function (Grid $grid) {
            $grid->column('id')->sortable();
            $grid->column('total_money','应付金额');
            $grid->column('order_time','下单时间');
            $grid->column('cart_id','购物车id');
            $grid->column('type','订单类型');
            $grid->column('coupon_price','优惠券金额');
            $grid->column('paid','支付状态');
            $grid->column('pay_time','支付时间');
            $grid->column('pay_type','支付类型');
            $grid->column('add_time','创建时间');
            $grid->column('status','订单状态');
            $grid->column('pay_postage','邮费');
            $grid->column('delivery_name','快递公司');
            $grid->column('delivery_type','物流类型');
            $grid->column('delivery_id','快递单号');
            $grid->column('created_at');
            $grid->column('updated_at')->sortable();
        
            $grid->filter(function (Grid\Filter $filter) {
                $filter->equal('id');
        
            });
        });
    }

    /**
     * Make a show builder.
     *
     * @param mixed $id
     *
     * @return Show
     */
    protected function detail($id)
    {
        return Show::make($id, new CmcPromotionsOrderlist(), function (Show $show) {
            $show->field('id');
            $show->field('total_money');
            $show->field('order_time');
            $show->field('cart_id');
            $show->field('type');
            $show->field('coupon_price');
            $show->field('paid');
            $show->field('pay_time');
            $show->field('pay_type');
            $show->field('add_time');
            $show->field('status');
            $show->field('mark');
            $show->field('is_del');
            $show->field('seckill_id');
            $show->field('bargain_id');
            $show->field('pay_postage');
            $show->field('delivery_name');
            $show->field('delivery_type');
            $show->field('delivery_id');
            $show->field('created_at');
            $show->field('updated_at');
        });
    }

    /**
     * Make a form builder.
     *
     * @return Form
     */
    protected function form()
    {
        return Form::make(new CmcPromotionsOrderlist(), function (Form $form) {
            $form->display('id');
            $form->text('total_money','应付金额');
            $form->datetime('order_time','下单时间');
            $form->text('cart_id','购物车id');
            $form->text('type','订单类型');
            $form->text('coupon_price','优惠券金额');
            $form->text('paid','支付状态');
            $form->datetime('pay_time','支付时间');
            $form->text('pay_type','支付类型');
            $form->datetime('add_time','创建时间');
            $form->text('status','订单状态');
            $form->text('mark','备注');
            $form->text('is_del','是否删除');
            $form->text('pintuan_id','拼团ID');
            $form->text('seckill_id','秒杀ID');
            $form->text('bargain_id','砍价ID');
            $form->text('pay_postage','邮费');
            $form->text('delivery_name','快递公司');
            $form->text('delivery_type','物流类型');
            $form->text('delivery_id','快递单号');
            $form->display('created_at');
            $form->display('updated_at');
        });
    }
}
